<template>
  <div id="superUser_updateOrder">
    <el-form ref="form" :model="form" label-width="80px" size="mini">
      <el-form-item label="昵称">
        <el-input v-model="name"></el-input>
      </el-form-item>

      <el-form-item label="停车场编号">
        <el-input v-model="parkingSpaceNumber"></el-input>
      </el-form-item>
      <el-form-item label="车牌号">
        <el-input v-model="licensePlateNumber"></el-input>
      </el-form-item>
      <el-form-item label="价格(元)">
        <el-input v-model="orderPrice"></el-input>
      </el-form-item>
      <el-form-item label="支付状态">
        <el-select v-model="orderState" placeholder="请选择状态">
          <el-option label="已支付" value="已支付"></el-option>
          <el-option label="未支付" value="未支付"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">立即创建</el-button>
        <el-button @click="cancel">取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  name: "superUser_updateOrder",
  data() {
    return {}
  },
  props: {
    id: null,
    name: null,
    parkingSpaceNumber: null,
    licensePlateNumber: null,
    orderPrice: null,
    orderState: null,
  },
  methods: {
    onSubmit() {
      console.log('submit!');
      if (this.orderState == "未支付") {
        this.orderState = 0
      } else {
        this.orderState = 1
      }
      console.log(this.id)
      console.log(this.name)
      console.log(this.parkingSpaceNumber)
      console.log(this.licensePlateNumber)
      console.log(this.orderPrice)
      console.log(this.orderState)
      this.$http.get("http://localhost:8088/superUser/updateOrder", {
        params: {
          id: this.id,
          name: this.name,
          parkingSpaceNumber: this.parkingSpaceNumber,
          licensePlateNumber: this.licensePlateNumber,
          orderPrice: this.orderPrice,
          orderState: this.orderState,
        }
      }).then(resp => {
        console.log(resp.data)
        this.$http.get("http://localhost:8088/superUser/findAllOrder").then(resp => {
          this.order = resp.data
          this.$router.push({
            name: 'superUser_order',
            query: {
              order: this.order,
            }
          }).catch(err => {
            console.log(err)
          })
        })
      })
    },
    cancel(){
      this.$http.get("http://localhost:8088/superUser/findAllOrder").then(resp => {
        this.order = resp.data
        this.$router.push({
          name: 'superUser_order',
          query: {
            order: this.order,
          }
        }).catch(err => {
          console.log(err)
        })
      })
    },
  },
  mounted() {
    if (this.orderState == 0) {
      this.orderState = '未支付'
    } else {
      this.orderState = '已支付'
    }
  }
}
</script>

<style scoped>

</style>